package log

import (
	"yunj/pkg/global"
	"yunj/pkg/yunj/app/controller/admin"
	"yunj/pkg/yunj/app/service/admin/logservice"

	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

// 成员日志管理
type Log struct {
	admin.Controller
}

// 列表
func (ctrl *Log) List(ctx *gin.Context) {
	ctrl.RenderTable(ctx, logservice.LogPage.ListBuilder(ctx, nil))
}

// 登录日志列表
func (ctrl *Log) LoginList(ctx *gin.Context) {
	ctrl.RenderTable(ctx, logservice.LogPage.ListBuilder(ctx, func(query *gorm.DB) (err error) {
		adminEntrance := global.Config.GetAppAdminEntrance()
		query.Where("(url like ? or url like ?)", adminEntrance+"/login%", adminEntrance+"/logout%")
		return
	}))
}
